package com.ruoyi.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.Deviceregister;
import com.ruoyi.system.service.IDeviceregisterService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 产品注册Controller
 * 
 * @author tianxingxia
 * @date 2025-02-07
 */
@RestController
@RequestMapping("/system/deviceregister")
public class DeviceregisterController extends BaseController
{
    @Autowired
    private IDeviceregisterService deviceregisterService;

    /**
     * 查询产品注册列表
     */
    @PreAuthorize("@ss.hasPermi('system:deviceregister:list')")
    @GetMapping("/list")
    public TableDataInfo list(Deviceregister deviceregister)
    {
        startPage();
        List<Deviceregister> list = deviceregisterService.selectDeviceregisterList(deviceregister);
        return getDataTable(list);
    }

    /**
     * 导出产品注册列表
     */
    @PreAuthorize("@ss.hasPermi('system:deviceregister:export')")
    @Log(title = "产品注册", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Deviceregister deviceregister)
    {
        List<Deviceregister> list = deviceregisterService.selectDeviceregisterList(deviceregister);
        ExcelUtil<Deviceregister> util = new ExcelUtil<Deviceregister>(Deviceregister.class);
        util.exportExcel(response, list, "产品注册数据");
    }

    /**
     * 获取产品注册详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:deviceregister:query')")
    @GetMapping(value = "/{registerId}")
    public AjaxResult getInfo(@PathVariable("registerId") Long registerId)
    {
        return success(deviceregisterService.selectDeviceregisterByRegisterId(registerId));
    }

    /**
     * 新增产品注册
     */
    @PreAuthorize("@ss.hasPermi('system:deviceregister:add')")
    @Log(title = "产品注册", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Deviceregister deviceregister)
    {
        return toAjax(deviceregisterService.insertDeviceregister(deviceregister));
    }

    /**
     * 修改产品注册
     */
    @PreAuthorize("@ss.hasPermi('system:deviceregister:edit')")
    @Log(title = "产品注册", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Deviceregister deviceregister)
    {
        return toAjax(deviceregisterService.updateDeviceregister(deviceregister));
    }

    /**
     * 删除产品注册
     */
    @PreAuthorize("@ss.hasPermi('system:deviceregister:remove')")
    @Log(title = "产品注册", businessType = BusinessType.DELETE)
	@DeleteMapping("/{registerIds}")
    public AjaxResult remove(@PathVariable Long[] registerIds)
    {
        return toAjax(deviceregisterService.deleteDeviceregisterByRegisterIds(registerIds));
    }
}
